package cn.fl.carloan.service.impl;

import java.util.List;

import cmm.comm.facade.upload.constant.SysUlFilesRecConstant;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.carloan.service.IOdrNoticeReadInfoService;
import cn.fl.carloan.transform.OdrNoticeReadInfoVOTransform;
import cn.fl.carloan.vo.OdrNoticeReadInfoVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import fl.carloan.facade.carloan.api.IOdrNoticeReadInfoApiService;
import fl.carloan.facade.carloan.condition.OdrClueInfoQC;
import fl.carloan.facade.carloan.condition.OdrNoticeReadInfoQC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import fl.carloan.facade.carloan.dto.OdrNoticeReadInfoDTO;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cmm.mid.core.framework.page.Pager;


/**
 * @Description: 公告阅读信息表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class OdrNoticeReadInfoServiceImpl implements IOdrNoticeReadInfoService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(OdrNoticeReadInfoServiceImpl.class);
	
	/**
	 * 自定义 API 自行注入需要的API服务
	 */
	@Autowired
	private IOdrNoticeReadInfoApiService odrNoticeReadInfoApiService;

	@Override
	public OdrNoticeReadInfoVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "selectById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "获取对象主键不能为空!");
		}
		//TODO 业务逻辑
		OdrNoticeReadInfoDTO dto = null;//this.自定义ApiService.selectOdrNoticeReadInfoDTOById(id);
		return OdrNoticeReadInfoVOTransform.toVO(dto);
	}

	@Override
	public Long add(OdrNoticeReadInfoVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "新增对象不存在!");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"新增对象不存在!");
		};
		//return this.odrNoticeReadInfoApiService.add(OdrNoticeReadInfoVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return null;
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeById", "删除对象主键不能为空!");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"删除对象主键不能为空!");
		};
		//return this.odrNoticeReadInfoApiService.removeOdrNoticeReadInfoDTOById(id);
		//TODO 业务逻辑
		return false;
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
		if(CollectionUtils.isEmpty(ids)){
			BaseLogUtils.info(logger, "removeByIds", "删除主键参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"删除对象主键不能为空!");
		};
		return false;
    }

	@Override
	public boolean modify(OdrNoticeReadInfoVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "modify", "修改对象不能为空!");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"修改对象不能为空!");
		};
		//return this.odrNoticeReadInfoApiService.modifyOdrNoticeReadInfoDTO(OdrNoticeReadInfoVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return false;
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page){
			page = new Pager();
		}
		//return this.odrNoticeReadInfoApiService.searchOdrNoticeReadInfoListPage(page);
		//TODO 业务逻辑
		return null;
	}

	@Override
	public void removeByNoticeId(Long noticeId) {
		odrNoticeReadInfoApiService.removeByNoticeId(noticeId);
	}

	@Override
	public String outExcel(OdrNoticeReadInfoQC qc) {
		if(qc == null){
			qc = new OdrNoticeReadInfoQC();
		}
		String path = this.odrNoticeReadInfoApiService.outExcel(qc);
		//  "/var/www/html/attachments/11000/odrclueinfo/20181204/XS20181204135418.xlsx"
		path = path.replace(PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_ROOT_PATH), PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_SERVER_PATH));
		//  "http://10.20.7.115:80/attachments/11000/odrclueinfo/20181204/XS20181204135418.xlsx"
		return path;
	}
}
